/**
 * @param {string} first
 * @param {string} second
 * @return {boolean}
 */
 var oneEditAway = function(first, second) {
  const diff = first.length - second.length;
  const judge = (a, b) => {
      let ret = 0;
      for(let i = 0; i < a.length; i++) {
          a[i] !== b[i] && ret++;
      }
      return ret <= 1;
  };
  if (diff === 1) {
      let i = 0;
      let flag = 0;
      while(i < second.length) {
          if(first[i + flag] !== second[i]) {
              if(flag) return false;
              flag++;
          } else {
              i++;
          }
      }
  } else if(diff === -1) {
      let i = 0;
      let flag = 0;
      while(i < first.length) {
          if(first[i] !== second[i + flag]) {
              if(flag) return false;
              flag++;
          } else {
              i++;
          }
      }
  } else if(diff === 0) {
      return judge(first, second);
  } else {
      return false;
  }
  return true;
};